package modules.citysection.bottom
{
import core.model.FriendModel;

import flash.display.MovieClip;

import framework.view.components.button.ButtonProxy;
import framework.view.components.container.PaginationListProxy;

/**
 * FriendUIProxy
 * @author jliang
 *
 */
public class FriendUIProxy extends PaginationListProxy
{
    //==========================================================================
    //  Constructor
    //==========================================================================
    public function FriendUIProxy()
    {
        super();
    }
    //==========================================================================
    //  Properties
    //==========================================================================
    [Inject]
    public var friendModel:FriendModel;
    
    protected function get giftBtn():ButtonProxy
    {
        return proxys["giftBtn"];
    }
    
    protected function get prevPageBtn():ButtonProxy
    {
        return proxys["prevPageBtn"];
    }
    
    protected function get nextPageBtn():ButtonProxy
    {
        return proxys["nextPageBtn"];
    }
    
    protected function get firstPageBtn():ButtonProxy
    {
        return proxys["firstPageBtn"];
    }
    
    protected function get lastPageBtn():ButtonProxy
    {
        return proxys["lastPageBtn"];
    }
    //==========================================================================
    //  Overridden methods: ComponentProxy
    //==========================================================================    
    override protected function get repeaterItemRenderClass():Class
    {
        return FriendItemRenderProxy;
    }
    
    override protected function get proxyMapping():Array
    {
        return [ 
            { skin:"giftBtn", classRef: ButtonProxy, id:"giftBtn", onClick: onClickGiftHandler },
            { skin:"firstPageBtn", classRef: ButtonProxy, id:"firstPageBtn", onClick: onClickToFirstPageHandler },
            { skin:"lastPageBtn", classRef: ButtonProxy, id:"lastPageBtn", onClick: onClickToLastPageHandler }
        ].concat(super.proxyMapping);
    }
    
    override public function parse(target:MovieClip):void
    {
        super.parse(target);
        
        skin.countLabel.text = String(friendModel.friendCount);
        
        setData(friendModel.friends);
    }
    //==========================================================================
    //  Event handlers
    //==========================================================================    
    protected function onClickGiftHandler():void
    {
        
    }
    
    protected function onClickToFirstPageHandler():void
    {
        goFirstPage(data, data.length);
    }
    
    protected function onClickToLastPageHandler():void
    {
        goLastPage(data, data.length);
    }
}
}







